```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring AOP 切面执行顺序指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .code-block {
            background-color: #282c34;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        .highlight {
            background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.8) 50%, rgba(255,255,255,0) 100%);
            animation: highlight 3s ease-in-out infinite;
        }
        @keyframes highlight {
            0% { background-position: -100% 0; }
            100% { background-position: 200% 0; }
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl text-center">
            <div class="flex justify-center mb-6">
                <span class="bg-white bg-opacity-20 px-4 py-1 rounded-full text-sm font-medium">Spring AOP 进阶指南</span>
            </div>
            <h1 class="text-4xl md:text-5xl font-bold mb-6 font-serif">掌握切面执行顺序的艺术</h1>
            <p class="text-xl md:text-2xl opacity-90 mb-10 max-w-3xl mx-auto font-serif">五种精细控制方法，构建高效可靠的AOP架构</p>
            <div class="flex justify-center space-x-4">
                <a href="#methods" class="bg-white text-indigo-700 px-6 py-3 rounded-lg font-medium hover:bg-opacity-90 transition duration-300">探索方法</a>
                <a href="#visual" class="border border-white text-white px-6 py-3 rounded-lg font-medium hover:bg-white hover:bg-opacity-10 transition duration-300">查看图表</a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 py-16">
        <!-- Intro Section -->
        <section class="mb-20">
            <div class="bg-white rounded-xl p-8 shadow-lg">
                <div class="flex items-center mb-6">
                    <div class="bg-indigo-100 w-12 h-12 rounded-full flex items-center justify-center mr-4">
                        <i class="fas fa-lightbulb text-indigo-600 text-xl"></i>
                    </div>
                    <h2 class="text-2xl font-bold text-gray-800">为什么需要控制切面顺序？</h2>
                </div>
                <p class="text-gray-700 mb-4">在复杂的Spring应用中，多个切面可能同时作用于同一个连接点(Join Point)。清晰的执行顺序控制可以确保：</p>
                <ul class="list-disc pl-5 space-y-2 text-gray-700">
                    <li>业务逻辑的正确性</li>
                    <li>日志、安全等关注点的合理执行</li>
                    <li>事务边界的明确划分</li>
                    <li>异常处理的优先级</li>
                </ul>
            </div>
        </section>

        <!-- Methods Section -->
        <section id="methods" class="mb-20">
            <h2 class="text-3xl font-bold mb-10 text-center font-serif">五种控制机制详解</h2>
            
            <!-- Method 1 -->
            <div class="grid md:grid-cols-12 gap-8 mb-16">
                <div class="md:col-span-5">
                    <div class="bg-white rounded-xl p-6 h-full card">
                        <div class="flex items-center mb-4">
                            <span class="bg-indigo-600 text-white w-8 h-8 rounded-full flex items-center justify-center mr-3">1</span>
                            <h3 class="text-xl font-bold text-gray-800">@Order注解</h3>
                        </div>
                        <p class="text-gray-700 mb-4">使用<code class="bg-gray-100 px-1 py-0.5 rounded">@Order</code>注解可以指定切面的优先级。数值越小优先级越高，执行顺序越靠前。</p>
                        <div class="code-block p-4 mb-4">
                            <pre class="text-gray-300 text-sm"><code>@Aspect
@Component
@Order(1) // 优先级高
public class AspectADemo {
    @Before("execution(* com.ts.service.*.*(..))")
    public void beforeAdvice() {
        System.out.println("AspectADemo - 前置通知");
    }
}</code></pre>
                        </div>
                        <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4">
                            <div class="flex">
                                <div class="flex-shrink-0 text-yellow-500">
                                    <i class="fas fa-exclamation-circle"></i>
                                </div>
                                <div class="ml-3">
                                    <p class="text-sm text-yellow-700">注意：默认情况下，未指定@Order的切面优先级最低</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="md:col-span-7">
                    <div class="p-6 bg-white rounded-xl h-full card">
                        <h4 class="font-medium text-gray-900 mb-3">执行顺序图示</h4>
                        <div class="mermaid">
                            graph LR
                                A[AspectADemo @Order(1)] --> B[AspectBDemo @Order(2)]
                                B --> C[目标方法]
                        </div>
                        <div class="mt-6">
                            <h4 class="font-medium text-gray-900 mb-2">适用场景</h4>
                            <ul class="flex flex-wrap gap-2">
                                <li class="bg-blue-100 text-blue-800 text-xs px-3 py-1 rounded-full">事务管理</li>
                                <li class="bg-blue-100 text-blue-800 text-xs px-3 py-1 rounded-full">安全检查</li>
                                <li class="bg-blue-100 text-blue-800 text-xs px-3 py-1 rounded-full">日志记录</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Method 2 -->
            <div class="grid md:grid-cols-12 gap-8 mb-16">
                <div class="md:col-span-7">
                    <div class="p-6 bg-white rounded-xl h-full card">
                        <h4 class="font-medium text-gray-900 mb-3">执行流程图示</h4>
                        <div class="mermaid">
                            graph TB
                                A[firstAdvice] --> B[secondAdvice]
                                B --> C[目标方法]
                        </div>
                    </div>
                </div>
                <div class="md:col-span-5">
                    <div class="bg-white rounded-xl p-6 h-full card">
                        <div class="flex items-center mb-4">
                            <span class="bg-indigo-600 text-white w-8 h-8 rounded-full flex items-center justify-center mr-3">2</span>
                            <h3 class="text-xl font-bold text-gray-800">切点匹配顺序</h3>
                        </div>
                        <p class="text-gray-700 mb-4">同一类中多个通知对同一个切点的处理顺序由它们在类中定义的顺序决定。</p>
                        <div class="code-block p-4">
                            <pre class="text-gray-300 text-sm"><code>@Aspect
@Component
public class AspectOrderDemo {
    @Before("execution(* com.ts.service.*.*(..))")
    public void firstAdvice() {
        System.out.println("第一个通知");
    }

    @Before("execution(* com.ts.service.*.*(..))")
    public void secondAdvice() {
        System.out.println("第二个通知");
    }
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Method 3 -->
            <div class="grid md:grid-cols-12 gap-8 mb-16">
                <div class="md:col-span-5">
                    <div class="bg-white rounded-xl p-6 h-full card">
                        <div class="flex items-center mb-4">
                            <span class="bg-indigo-600 text-white w-8 h-8 rounded-full flex items-center justify-center mr-3">3</span>
                            <h3 class="text-xl font-bold text-gray-800">配置顺序</h3>
                        </div>
                        <p class="text-gray-700 mb-4">通过XML配置或Java配置显式指定切面顺序。</p>
                        <div class="code-block p-4 mb-4">
                            <pre class="text-gray-300 text-sm"><code>@Configuration
@EnableAspectJAutoProxy
public class AppConfig {
    @Bean
    public AspectADemo aspectA() { return new AspectADemo(); }
    
    @Bean
    public AspectBDemo aspectB() { return new AspectBDemo(); }
}</code></pre>
                        </div>
                        <p class="text-sm text-gray-600">注意：这种情况下切面将按照在配置类中定义的顺序执行</p>
                    </div>
                </div>
                <div class="md:col-span-7">
                    <div class="p-6 bg-white rounded-xl h-full card">
                        <h4 class="font-medium text-gray-900 mb-3">执行顺序图示</h4>
                        <div class="mermaid">
                            graph LR
                                A[XML配置] --> B[先声明的切面]
                                B --> C[后声明的切面]
                        </div>
                        <div class="mt-6">
                            <h4 class="font-medium text-gray-900 mb-2">适用场景</h4>
                            <ul class="flex flex-wrap gap-2">
                                <li class="bg-green-100 text-green-800 text-xs px-3 py-1 rounded-full">传统XML配置</li>
                                <li class="bg-green-100 text-green-800 text-xs px-3 py-1 rounded-full">明确顺序需求</li>
                                <li class="bg-green-100 text-green-800 text-xs px-3 py-1 rounded-full">模块化配置</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Method 4 -->
            <div class="grid md:grid-cols-12 gap-8 mb-16">
                <div class="md:col-span-7">
                    <div class="p-6 bg-white rounded-xl h-full card">
                        <h4 class="font-medium text-gray-900 mb-3">继承关系图示</h4>
                        <div class="mermaid">
                            classDiagram
                                ParentAspect <|-- ChildAspect
                                ParentAspect : +before()
                                ChildAspect : +before()
                        </div>
                    </div>
                </div>
                <div class="md:col-span-5">
                    <div class="bg-white rounded-xl p-6 h-full card">
                        <div class="flex items-center mb-4">
                            <span class="bg-indigo-600 text-white w-8 h-8 rounded-full flex items-center justify-center mr-3">4</span>
                            <h3 class="text-xl font-bold text-gray-800">继承和代理</h3>
                        </div>
                        <p class="text-gray-700 mb-4">继承关系和代理创建顺序会影响切面执行顺序。</p>
                        <div class="space-y-2">
                            <div class="flex items-start">
                                <div class="flex-shrink-0 mt-1">
                                    <span class="w-5 h-5 bg-purple-100 text-purple-800 rounded-full flex items-center justify-center text-xs">A</span>
                                </div>
                                <p class="ml-2 text-gray-700">子类切面会覆盖父类切面</p>
                            </div>
                            <div class="flex items-start">
                                <div class="flex-shrink-0 mt-1">
                                    <span class="w-5 h-5 bg-purple-100 text-purple-800 rounded-full flex items-center justify-center text-xs">B</span>
                                </div>
                                <p class="ml-2 text-gray-700">CGLIB和JDK代理行为不同</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Method 5 -->
            <div class="grid md:grid-cols-12 gap-8">
                <div class="md:col-span-5">
                    <div class="bg-white rounded-xl p-6 h-full card">
                        <div class="flex items-center mb-4">
                            <span class="bg-indigo-600 text-white w-8 h-8 rounded-full flex items-center justify-center mr-3">5</span>
                            <h3 class="text-xl font-bold text-gray-800">编程逻辑</h3>
                        </div>
                        <p class="text-gray-700 mb-4">在通知方法中显式调用其他切面逻辑。</p>
                        <div class="code-block p-4">
                            <pre class="text-gray-300 text-sm"><code>@Aspect
@Component
public class LoggingAspect {
    @Autowired
    private SecurityAspect securityAspect;
    
    @Before("execution(* com.ts.service.*.*(..))")
    public void logBefore(JoinPoint joinPoint) {
        securityAspect.checkPermission();
        // 日志记录逻辑
    }
}</code></pre>
                        </div>
                    </div>
                </div>
                <div class="md:col-span-7">
                    <div class="p-6 bg-white rounded-xl h-full card">
                        <h4 class="font-medium text-gray-900 mb-3">执行流程图示</h4>
                        <div class="mermaid">
                            graph LR
                                A[LoggingAspect] --> B[调用SecurityAspect]
                                B --> C[继续LoggingAspect]
                                C --> D[目标方法]
                        </div>
                        <div class="mt-6">
                            <h4 class="font-medium text-gray-900 mb-2">适用场景</h4>
                            <ul class="flex flex-wrap gap-2">
                                <li class="bg-red-100 text-red-800 text-xs px-3 py-1 rounded-full">强制顺序</li>
                                <li class="bg-red-100 text-red-800 text-xs px-3 py-1 rounded-full">条件执行</li>
                                <li class="bg-red-100 text-red-800 text-xs px-3 py-1 rounded-full">复杂逻辑</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization Section -->
        <section id="visual" class="mb-20">
            <div class="bg-white rounded-xl shadow-lg overflow-hidden">
                <div class="p-6 bg-gradient-to-r from-indigo-500 to-purple-600 text-white">
                    <h2 class="text-2xl font-bold font-serif">切面执行顺序可视化</h2>
                    <p class="opacity-90">五种机制的综合应用流程图</p>
                </div>
                <div class="p-6">
                    <div class="mermaid">
                        graph TD
                            A[开始] --> B{控制方式}
                            B -->|@Order| C[数值小的先执行]
                            B -->|切点匹配| D[同一切面中定义的顺序]
                            B -->|配置顺序| E[配置文件中声明的顺序]
                            B -->|继承代理| F[子类覆盖父类]
                            B -->|编程逻辑| G[显式调用]
                            C --> H[目标方法]
                            D --> H
                            E --> H
                            F --> H
                            G --> H
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="mb-20">
            <div class="bg-white rounded-xl p-8 shadow-lg">
                <h2 class="text-2xl font-bold mb-6 font-serif">最佳实践总结</h2>
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <div class="flex items-start mb-6">
                            <div class="flex-shrink-0 mt-1">
                                <div class="w-10 h-10 bg-indigo-100 rounded-full flex items-center justify-center">
                                    <i class="fas fa-check text-indigo-600"></i>
                                </div>
                            </div>
                            <div class="ml-4">
                                <h3 class="text-lg font-medium text-gray-900">推荐做法</h3>
                                <ul class="mt-2 space-y-2 text-gray-700">
                                    <li class="flex items-start">
                                        <span class="text-indigo-500 mr-2">•</span>
                                        <span>优先使用@Order注解明确优先级</span>
                                    </li>
                                    <li class="flex items-start">
                                        <span class="text-indigo-500 mr-2">•</span>
                                        <span>保持切面类中通知方法的逻辑顺序</span>
                                    </li>
                                    <li class="flex items-start">
                                        <span class="text-indigo-500 mr-2">•</span>
                                        <span>在配置类中合理安排切面注册顺序</span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div>
                        <div class="flex items-start mb-6">
                            <div class="flex-shrink-0 mt-1">
                                <div class="w-10 h-10 bg-red-100 rounded-full flex items-center justify-center">
                                    <i class="fas fa-times text-red-600"></i>
                                </div>
                            </div>
                            <div class="ml-4">
                                <h3 class="text-lg font-medium text-gray-900">避免做法</h3>
                                <ul class="mt-2 space-y-2 text-gray-700">
                                    <li class="flex items-start">
                                        <span class="text-red-500 mr-2">•</span>
                                        <span>过度依赖默认顺序</span>
                                    </li>
                                    <li class="flex items-start">
                                        <span class="text-red-500 mr-2">•</span>
                                        <span>复杂的继承关系导致顺序混乱</span>
                                    </li>
                                    <li class="flex items-start">
                                        <span class="text-red-500 mr-2">•</span>
                                        <span>编程逻辑中过多硬编码调用</span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="mt-8 p-6 bg-indigo-50 rounded-lg border border-indigo-100">
                    <div class="flex">
                        <div class="flex-shrink-0">
                            <i class="fas fa-info-circle text-indigo-500 text-xl"></i>
                        </div>
                        <div class="ml-3">
                            <h3 class="text-lg font-medium text-indigo-800">调试技巧</h3>
                            <div class="mt-2 text-indigo-700">
                                <p>使用<code class="bg-indigo-100 px-1 py-0.5 rounded">JoinPoint.getThis()</code>和<code class="bg-indigo-100 px-1 py-0.5 rounded">JoinPoint.getTarget()</code>方法检查代理对象和目标对象，帮助理解执行顺序。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12">
        <div class="container mx-auto max-w-5xl px-4">
            <div class="flex flex-col items-center">
                <div class="mb-4">
                    <span class="text-2xl font-serif">技术小馆</span>
                </div>
                <div class="mb-6">
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-300">http://www.yuque.com/jtostring</a>
                </div>
                <div class="flex space-x-4">
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-github text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-twitter text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-linkedin text-xl"></i>
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            themeVariables: {
                primaryColor: '#E5E7EB',
                primaryBorderColor: '#4B5563',
                primaryTextColor: '#111827',
                lineColor: '#9CA3AF'
            }
        });
    </script>
</body>
</html>
```